<template>
	<view class="wrapper">
		<view class="put_name_box">
			<view class="name">昵称</view>
			<input type="text" placeholder="请输入姓名" class="name_txt" placeholder-class="f30" v-model="nickname" />
		</view>
		<button type="primary" class="sub" @tap="updateUser">确定</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			nickname: uni.getStorageSync('userinfo').nickname
		};
	},
	methods: {
		updateUser() {
			if (this.nickname == '') {
				this.$sToast('昵称不能为空');
				return;
			}
			this.$ajax(this.apiList.userUpdate, {
				nickname: this.nickname
			}).then(res => {
				this.$sToast('修改成功');
				let userinfo=uni.getStorageSync('userinfo')
				userinfo.nickname=this.nickname
				uni.setStorageSync('userinfo',userinfo)
				this.$back()
			});
		}
	}
};
</script>

<style>
.wrapper {
	background-color: #f3f3f3;
}
.put_name_box {
	height: 104rpx;
	background: rgba(255, 255, 255, 1);
	display: flex;
	flex-direction: row;
	align-items: center;
	border-bottom: 1rpx solid rgba(224, 224, 224, 1);
	border-top: 1rpx solid rgba(224, 224, 224, 1);
	margin-bottom: 20rpx;
}
.right_arr {
	width: 12rpx;
	height: 24rpx;
	margin-right: 30rpx;
}
.name_txt {
	flex: 1;
}
.name {
	font-size: 30rpx;
	font-weight: 500;
	color: rgba(102, 102, 102, 1);
	margin: 0 31rpx 0 32rpx;
}
.sub {
	width: 710rpx;
	height: 80rpx;
	background: rgba(2, 151, 254, 1);
	border-radius: 4rpx;
	font-size: 30rpx;
	font-weight: 500;
	color: rgba(255, 255, 255, 1);
}
</style>
